package com.mvc.web.common.base;

import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.servlet.support.RequestContext;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import java.util.Locale;

public class BaseController {

    protected Logger logger;

    protected HttpServletRequest request;  
    protected HttpServletResponse response;  
    protected HttpSession session;  
      
    @ModelAttribute
    public void setReqAndRes(HttpServletRequest request, HttpServletResponse response){  
        this.request = request;  
        this.response = response;  
        this.session = request.getSession();  
    } 
    
    public BaseController() {
        logger = Logger.getLogger(this.getClass().getName());
    }

    public Locale getLocale(HttpServletRequest request) {
        RequestContext requestContext = new RequestContext(request);
        Locale locale = requestContext.getLocale();
        return locale;
    }
}
